package com.ruoyi.disasterassessment.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.disasterassessment.dto.AlarmWarnPredictionHistoryDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.disasterassessment.mapper.AlarmWarnPredictionHistoryMapper;
import com.ruoyi.disasterassessment.domain.AlarmWarnPredictionHistory;
import com.ruoyi.disasterassessment.service.IAlarmWarnPredictionHistoryService;

/**
 * 预警预测模拟历史数据Service业务层处理
 * 
 * @author hcc
 * @date 2023-12-20
 */
@Service
public class AlarmWarnPredictionHistoryServiceImpl implements IAlarmWarnPredictionHistoryService 
{
    @Autowired
    private AlarmWarnPredictionHistoryMapper alarmWarnPredictionHistoryMapper;

    /**
     * 查询预警预测模拟历史数据
     * 
     * @param id 预警预测模拟历史数据主键
     * @return 预警预测模拟历史数据
     */
    @Override
    public AlarmWarnPredictionHistory selectAlarmWarnPredictionHistoryById(String id)
    {
        return alarmWarnPredictionHistoryMapper.selectAlarmWarnPredictionHistoryById(id);
    }

    /**
     * 查询预警预测模拟历史数据列表
     * 
     * @param alarmWarnPredictionHistory 预警预测模拟历史数据
     * @return 预警预测模拟历史数据
     */
    @Override
    public List<AlarmWarnPredictionHistory> selectAlarmWarnPredictionHistoryList(AlarmWarnPredictionHistory alarmWarnPredictionHistory)
    {
        return alarmWarnPredictionHistoryMapper.selectAlarmWarnPredictionHistoryList(alarmWarnPredictionHistory);
    }

    /**
     * 新增预警预测模拟历史数据
     * 
     * @param alarmWarnPredictionHistory 预警预测模拟历史数据
     * @return 结果
     */
    @Override
    public int insertAlarmWarnPredictionHistory(AlarmWarnPredictionHistory alarmWarnPredictionHistory)
    {
        alarmWarnPredictionHistory.setCreateTime(DateUtils.getNowDate());
        return alarmWarnPredictionHistoryMapper.insertAlarmWarnPredictionHistory(alarmWarnPredictionHistory);
    }

    /**
     * 修改预警预测模拟历史数据
     * 
     * @param alarmWarnPredictionHistory 预警预测模拟历史数据
     * @return 结果
     */
    @Override
    public int updateAlarmWarnPredictionHistory(AlarmWarnPredictionHistory alarmWarnPredictionHistory)
    {
        alarmWarnPredictionHistory.setUpdateTime(DateUtils.getNowDate());
        return alarmWarnPredictionHistoryMapper.updateAlarmWarnPredictionHistory(alarmWarnPredictionHistory);
    }

    /**
     * 批量删除预警预测模拟历史数据
     * 
     * @param ids 需要删除的预警预测模拟历史数据主键
     * @return 结果
     */
    @Override
    public int deleteAlarmWarnPredictionHistoryByIds(String[] ids)
    {
        return alarmWarnPredictionHistoryMapper.deleteAlarmWarnPredictionHistoryByIds(ids);
    }

    /**
     * 删除预警预测模拟历史数据信息
     * 
     * @param id 预警预测模拟历史数据主键
     * @return 结果
     */
    @Override
    public int deleteAlarmWarnPredictionHistoryById(String id)
    {
        return alarmWarnPredictionHistoryMapper.deleteAlarmWarnPredictionHistoryById(id);
    }

    /**
     * 通过modelId获取预警预测模拟历史数据详细信息
     * @param modelId
     * @return
     */
    @Override
    public List<AlarmWarnPredictionHistoryDto> getAlarmWarnPredictionHistoryByModelId(String modelId) {
        List<AlarmWarnPredictionHistory> alarmWarnPredictionHistoryList = alarmWarnPredictionHistoryMapper.getAlarmWarnPredictionHistoryByModelId(modelId);
        List<AlarmWarnPredictionHistoryDto> list = alarmWarnPredictionHistoryList.stream().map(alarmWarnPredictionHistory -> {
            AlarmWarnPredictionHistoryDto alarmWarnPredictionHistoryDto = new AlarmWarnPredictionHistoryDto();
            BeanUtils.copyProperties(alarmWarnPredictionHistory, alarmWarnPredictionHistoryDto);
            return alarmWarnPredictionHistoryDto;
        }).collect(Collectors.toList());
        return list;
    }
}
